<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('退回绩效数据列表')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="dept-form">
                <div class="select-list">
                    <ul>
                        <li>
                            姓名：<input type="text" name="name"/>
                        </li>
                        <li>
                            工号：<input type="text" name="badge"/>
                        </li>
                        <li>
                            部门：
                            <select class="form-control" id="deptId" name="deptId">
                                <option value="">请选择</option>
                                <option th:each="dep:${depList}" th:value="${dep.deptId }"
                                        th:text="${dep.deptName }"></option>
                            </select>
                        </li>
                        <li>
                            岗位：
                            <select class="form-control" id="jobId" name="jobId">
                                <option value="">请选择</option>
                                <option th:each="job:${jobList}" th:value="${job.jobId }"
                                        th:text="${job.jobName }"></option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>

<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">

    var prefix = ctx + "acvScoringDataBackManage"

    $(function () {
        var options = {
            code: "userId",
            uniqueId: "userId",
            url: prefix + "/list",
            createUrl: prefix + "/add/{id}",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove/{id}",
            modalName: "用户",
            columns: [
                {
                    field: 'years',
                    title: '年份'
                },
                {
                    field: 'months',
                    title: '月份'
                },
                {
                    field: 'badge',
                    title: '工号'
                },
                {
                    field: 'examineeName',
                    title: '姓名'
                },
                {
                    field: 'deptName',
                    title: '二级部门'
                },
                {
                    field: 'tertiaryDeptName',
                    title: '三级部门'
                },
                {
                    field: 'jobName',
                    title: '岗位'
                },
                {
                    field: 'scoreTotal',
                    title: '绩效值'
                },
                {
                    field: 'remarksTotal',
                    title: '备注'
                },
                {
                    title: '绩效考核',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="toAssessment(\'' + row.examineeId + '\',\'' + row.examineeName + '\',\'' + row.years + '\',\'' + row.months + '\',\'' + row.badge + '\',\'' + row.deptName + '\',\'' + row.jobName + '\',\'' + row.scoringId + '\',\'' + row.remarksTotal + '\',\'' + row.scoreTotal + '\')">进入考核</a> ');
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="backSubmit(\'' + row.scoringId + '\')">提交</a> ');
                        return actions.join('');
                    }
                }
            ]
        };
        $.table.init(options);
    });


    function toAssessment(examineeId, name, years, months, badge, deptName, jobName, scoringId, remarksTotal, scoreTotal) {
        //$.modal.openFull("工号:" + badge + "  姓名:" + name + "  部门:" + deptName + "  岗位:" + jobName + "  考核日期:" + years + "年" + months + "月", prefix + "/toScoring?examineeId=" + examineeId);
        window.open(ctx + "acvScoringManage/toScoring?examineeId=" + examineeId + "&years=" + years + "&months=" + months + "&scoringId=" + scoringId + "&remarksTotal=" + remarksTotal + "&scoreTotal=" + scoreTotal + "&table=acv_scoring_back");
    }

    function backSubmit(scoringId){
        $.modal.confirm("确定提交吗？", function () {
            $.ajax({
                async: false,
                url: ctx + "acvScoringDataBackManage/backSubmit",
                data: {
                    "scoringId": scoringId
                },
                type: "post",
                dataType: "json",
                success: function (data) {
                    if(data.code == 0){
                        $.modal.alertSuccess('提交成功');
                        $.table.search();
                    }
                }
            });
        });
    }

</script>
</body>
</html>